import Sequelize from 'sequelize';
import baseDao from '../lib/baseDao.js'; // 数据库操作

const Modal = baseDao.sequelize.define('t_order', {
  // 属性
  id: {
    type: Sequelize.INTEGER,
    primaryKey: true, // 主键
    autoIncrement: true, // 自增
    allowNull: true,
    validate: {
      len: [1, 50]
    }
  },
  userId: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '所属用户ID'
  },
  goodsId: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '商品ID'
  },
  tradeParentId: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 100]
    },
    comment: '买家在淘宝后台显示的订单编号'
  },
  tradeId: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 100]
    },
    comment: '订单下商品编号'
  },
  itemTitle: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 100]
    },
    comment: '商品标题'
  },
  sellerShopTitle: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 200]
    },
    comment: '店铺名'
  },
  itemImg: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 200]
    },
    comment: '商品图片'
  },
  itemNum: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '商品数量'
  },
  itemPrice: {
    type: Sequelize.FLOAT(10,2),
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '商品单价'
  },
  pubSharePreFee: {
    type: Sequelize.FLOAT(10,2),
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '付款预估收入=付款金额*提成。指买家付款金额为基数，预估您可能获得的收入。因买家退款等原因，可能与结算预估收入不一致'
  },
  alipayTotalPrice: {
    type: Sequelize.FLOAT(10,2),
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '买家拍下付款的金额（不包含运费金额）'
  },
  payPrice: {
    type: Sequelize.FLOAT(10,2),
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '买家确认收货的付款金额（不包含运费金额）'
  },
  totalCommissionFee: {
    type: Sequelize.FLOAT(10,2),
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '佣金金额=结算金额*佣金比率'
  },
  returnGold: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '结算后返利给用户的积分'
  },
  itemCategoryName: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '商品所属的根类目，即一级类目的名称'
  },
  status: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    defaultValue: 0,
    comment: '加款状态：0未处理1已处理'
  },
  tkStatus: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '3：订单结算，12：订单付款， 13：订单失效，14：确认收货'
  },
  refundTag: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 10]
    },
    comment: '维权标签，0 含义为非维权 1 含义为维权订单'
  },
  tkCreateTime: {
    type: Sequelize.INTEGER,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '订单创建的时间，该时间同步淘宝，可能会略晚于买家在淘宝的订单创建时间'
  },
  tbPaidTime: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '订单在淘宝拍下付款的时间'
  },
  tkEarningTime: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '订单确认收货后且商家完成佣金支付的时间'
  },
  clickTime: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '通过推广链接达到商品、店铺详情页的点击时间'
  },
  adzoneName: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '推广位管理下的自定义推广位名称'
  },
  adzoneId: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '推广位管理下的推广位名称对应的ID，同时也是pid=mm_1_2_3中的“3”这段数字'
  },
  terminalType: {
    type: Sequelize.STRING,
    allowNull: true,
    validate: {
      len: [0, 50]
    },
    comment: '成交平台：无线/PC'
  },
}, {
    // 参数
    indexes: [{ name: 'orderid_itemid', unique: true, fields: ['trade_parent_id', 'trade_id'] }], // 索引 
  });

//向外暴露
export default {
  Modal,
}